package com.example.weblending.domain.statistics;

import com.example.weblending.vo.AnalyzeColumn;
import com.example.weblending.vo.CsvInputColumn;

public class InterestRate extends StatisticsBase{

    @Override
    public void init() {
        this.field.add(new StatisticsField("小于3"));
        this.field.add(new StatisticsField("3-5"));
        this.field.add(new StatisticsField("5-10"));
        this.field.add(new StatisticsField("10-15"));
        this.field.add(new StatisticsField("15-20"));
        this.field.add(new StatisticsField("20-25"));
        this.field.add(new StatisticsField("25-30"));
        this.field.add(new StatisticsField("30以上"));

    }

    @Override
    public void insert(AnalyzeColumn cleanColumn) {
        set(cleanColumn.getInterestRate(),cleanColumn.getIs(),cleanColumn);
    }
    @Override
    public void set(float num, float percent, CsvInputColumn cleanColumn) {
        if (num>30){
            this.add(8,percent);
            cleanColumn.setInterestRate(8);
        }
        else if (num>25){
            this.add(7,percent);
            cleanColumn.setInterestRate(7);
        }
        else if (num>20){
            this.add(6,percent);
            cleanColumn.setInterestRate(6);
        }
        else if (num>15){
            this.add(5,percent);
            cleanColumn.setInterestRate(5);
        }
        else if (num>10){
            this.add(4,percent);
            cleanColumn.setInterestRate(4);
        }
        else if (num>5){
            this.add(3,percent);
            cleanColumn.setInterestRate(3);
        }
        else if (num>3){
            this.add(2,percent);
            cleanColumn.setInterestRate(2);
        }
        else{
            this.add(1,percent);
            cleanColumn.setInterestRate(1);
        }
    }
}
